<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>nlfilt2</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="nlfilt.html" title="nlfilt" />
    <link rel="next" href="noise.html" title="noise" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">nlfilt2</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="nlfilt.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="noise.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="nlfilt2"></a>
      <div class="titlepage"></div>
      <a id="IndexNlfilt2" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">nlfilt2</span>
        </h2>
        <p>nlfilt2 — 
      A filter with a non-linear effect and blowup protection.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp127249776"></a>
        <h2>Description</h2>
        <p>
      Implements the filter:
      </p>
        <div class="literallayout">
          <p><br />
Y{n} =tanh(a Y{n-1} + b Y{n-2} + d Y^2{n-L} + X{n} - C)<br />
      </p>
        </div>
        <p>
      described in Dobson and Fitch (ICMC'96) as modified by Risto Holopainen.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp127325552"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>nlfilt2</strong></span> ain, ka, kb, kd, kC, kL</pre>
      </div>
      <div class="refsect1">
        <a id="idp127327712"></a>
        <h2>Performance</h2>
        <p>
      </p>
        <div class="orderedlist">
          <ol class="orderedlist" type="1">
            <li class="listitem">
              <p>
            Non-linear effect. The range of parameters are:
            </p>
              <div class="literallayout">
                <p><br />
  a = b = 0<br />
  d = 0.8, 0.9, 0.7<br />
  C = 0.4, 0.5, 0.6<br />
  L = 20<br />
            </p>
              </div>
              <p>
            This affects the lower register most but there are audible effects over the whole range. We suggest that it may be useful for coloring drums, and for adding arbitrary highlights to notes.
          </p>
            </li>
            <li class="listitem">
              <p>
            Low Pass with non-linear. The range of parameters are:
            </p>
              <div class="literallayout">
                <p><br />
  a = 0.4<br />
  b = 0.2<br />
  d = 0.7<br />
  C = 0.11<br />
  L = 20, ... 200<br />
            </p>
              </div>
              <p>
            There are instability problems with this variant but the effect is more pronounced of the lower register, but is otherwise much like the pure comb. Short values of <span class="emphasis"><em>L</em></span> can add attack to a sound.
          </p>
            </li>
            <li class="listitem">
              <p>
            High Pass with non-linear. The range of parameters are:
            </p>
              <div class="literallayout">
                <p><br />
  a = 0.35<br />
  b = -0.3<br />
  d = 0.95<br />
  C = 0,2, ... 0.4<br />
  L = 200<br />
            </p>
              </div>
              <p>
          </p>
            </li>
            <li class="listitem">
              <p>
            High Pass with non-linear. The range of parameters are:
            </p>
              <div class="literallayout">
                <p><br />
  a = 0.7<br />
  b = -0.2, ... 0.5<br />
  d = 0.9<br />
  C = 0.12, ... 0.24<br />
  L = 500, 10<br />
            </p>
              </div>
              <p>
            The high pass version is less likely to oscillate. It adds scintillation to medium-high registers. With a large delay <span class="emphasis"><em>L</em></span> it is a little like a reverberation, while with small values there appear to be formant-like regions. There are arbitrary color changes and resonances as the pitch changes. Works well with individual notes.
          </p>
            </li>
          </ol>
        </div>
        <p>
    </p>
        <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Warning: Warning">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Warning]" src="images/warning.png" />
              </td>
              <th align="left">Warning</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        The "useful" ranges of parameters are not yet mapped.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp127340368"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the nlfilt2 opcode. It uses the file <a class="ulink" href="examples/nlfilt2.csd" target="_top"><em class="citetitle">nlfilt2.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp127342224"></a>
          <p class="title">
            <strong>Example 539. Example of the nlfilt2 opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac  <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o nlfilt.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1	<span class="comment">;unfiltered noise</span>

asig <span class="opc">rand</span> .7
     <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>

<span class="oblock">instr</span> 2	<span class="comment">;filtered noise</span>

ka <span class="op">=</span> p4
kb <span class="op">=</span> p5
kd <span class="op">=</span> p6
kC <span class="op">=</span> p7
kL <span class="op">=</span> p8
asig  <span class="opc">rand</span> .3
afilt <span class="opc">nlfilt2</span> asig, ka, kb, kd, kC, kL
      <span class="opc">outs</span>    afilt, afilt
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">i</span> 1 0 2				<span class="comment">; unfiltered</span>

<span class="comment">;        a    b    d    C    L</span>
<span class="stamnt">i</span> 2 2 2  0    0   0.8  0.5  20	<span class="comment">; non-linear effect</span>
<span class="stamnt">i</span> 2 + 2 .4   0.2  0.7  0.11 200	<span class="comment">; low=pass with non-linear</span>
<span class="stamnt">i</span> 2 + 2 0.35 -0.3 0.95 0.1  200	<span class="comment">; high-pass with non-linear</span>
<span class="stamnt">i</span> 2 + 2 0.7 -0.2  0.9  0.2  20 	<span class="comment">; high-pass with non-linear</span>

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp127346512"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: John ffitch</td>
          </tr>
          <tr>
            <td>University of Bath/Codemist Ltd.</td>
          </tr>
          <tr>
            <td>Bath, UK</td>
          </tr>
          <tr>
            <td>2012</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 5.19</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="nlfilt.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="noise.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">nlfilt </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> noise</td>
        </tr>
      </table>
    </div>
  </body>
</html>
